<template>
	<a href="#/">Home</a>
	<a href="#/about">About</a>
	<a href="#/non-existent-path">Broken Link</a>
	<component :is="currentView"></component>
</template>
  
<script setup>
	import { ref, computed } from "vue" 
	import Home from "@/components/Home.vue"
	import About from "@/components/About.vue"
	import NotFound from "@/components/NotFound.vue"
	
	const routes = {
		'/': Home,
		'/about': About 
	}
	const currentPath = ref(window.location.hash) 
	window.addEventListener('hashchange', () => {
		currentPath.value = window.location.hash
	})
	const currentView = computed(() => {
		return routes[currentPath.value.slice(1) || '/'] || NotFound
	})
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  margin-top: 60px;
}
a {
	padding: 20px;
}
</style>
